import React, { useState, useEffect } from 'react';

import { Divider, Radio, Table } from 'antd';

const GoodsList = ({ list, columns }) => {
  const [selectionType, setSelectionType] = useState('checkbox');

  const data = [
    {
      id: 1,
      image: 'http://cba.itlike.com/public/uploads/10001/20230321/8f505c6c437fc3d4b4310b57b1567544.jpg',
      name: '三星手机 SAMSUNG Galaxy S23 8GB+256GB 超视觉夜拍系统 超清夜景 悠雾紫 5G手机 游戏拍照旗舰机s23',
      price_max: 0.01,
      line_price_max: 9899.0,
    },
    {
      id: 2,
      image: 'http://cba.itlike.com/public/uploads/10001/20230321/8f505c6c437fc3d4b4310b57b1567544.jpg',
      name: '三星手机 SAMSUNG Galaxy S23 8GB+256GB 超视觉夜拍系统 超清夜景 悠雾紫 5G手机 游戏拍照旗舰机s23',
      price_max: 0.01,
      line_price_max: 9899.0,
    },
    {
      id: 3,
      image: 'http://cba.itlike.com/public/uploads/10001/20230321/8f505c6c437fc3d4b4310b57b1567544.jpg',
      name: '三星手机 SAMSUNG Galaxy S23 8GB+256GB 超视觉夜拍系统 超清夜景 悠雾紫 5G手机 游戏拍照旗舰机s23',
      price_max: 0.01,
      line_price_max: 9899.0,
    },
    {
      id: 4,
      image: 'http://cba.itlike.com/public/uploads/10001/20230321/8f505c6c437fc3d4b4310b57b1567544.jpg',
      name: '三星手机 SAMSUNG Galaxy S23 8GB+256GB 超视觉夜拍系统 超清夜景 悠雾紫 5G手机 游戏拍照旗舰机s23',
      price_max: 0.01,
      line_price_max: 9899.0,
    },
    {
      id: 5,
      image: 'http://cba.itlike.com/public/uploads/10001/20230321/8f505c6c437fc3d4b4310b57b1567544.jpg',
      name: '三星手机 SAMSUNG Galaxy S23 8GB+256GB 超视觉夜拍系统 超清夜景 悠雾紫 5G手机 游戏拍照旗舰机s23',
      price_max: 0.01,
      line_price_max: 9899.0,
    },
  ];

  const detail = list || data;
  const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
      console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
    },
    getCheckboxProps: (record) => ({
      disabled: record.name === 'Disabled User',
      // Column configuration not to be checked
      name: record.name,
    }),
  };

  return (
    <Table
      rowSelection={{
        type: selectionType,
        ...rowSelection,
      }}
      columns={columns}
      // dataSource={data}
      dataSource={detail}
    />
  );
};

export default GoodsList;
